package com.winkyle.woodenfish.controller.activity;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.winkyle.woodenfish.R;
import com.winkyle.woodenfish.databinding.ActivityLoadUrlBinding;
import com.winkyle.woodenfish.factory.presenterfactory.CreatePresenter;
import com.winkyle.woodenfish.mvpview.LoadUrlView;
import com.winkyle.woodenfish.presenter.LoalUrlPresent;
/**
 * @author winkyle
 * @date 2018/06/13
 * @description 继承自 {@link AbstractMvpActivity}的活动类LoadUrlActivity，app的网页加载页
 */
@CreatePresenter(value = LoalUrlPresent.class)
public class LoadUrlActivity extends AbstractMvpActivity<LoadUrlView,LoalUrlPresent> implements LoadUrlView{
    private String TAG = "LoadUrlActivity";
    private ActivityLoadUrlBinding activityLoadurlBinding;

    /**
     * @description 活动创建，指定layout布局
     * @param savedInstanceState 保存的活动状态的数据
     * @return
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activityLoadurlBinding = DataBindingUtil.setContentView(this, R.layout.activity_load_url);
        initActivity();
    }
    /**
     * @description 初始化活动的一些数据和动作
     * @return
     */
    public void initActivity() {
        WebSettings webSettings = activityLoadurlBinding.loadurl.getSettings();
        //设置支持缩放
        webSettings.setBuiltInZoomControls(true);

        activityLoadurlBinding.loadurl.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;// 返回false
            }
        });
        Log.d("CookiesAdd",getIntent().getStringExtra("url"));
        //加载需要显示的网页
        activityLoadurlBinding.loadurl.loadUrl(getIntent().getStringExtra("url"));
        //设置Web视图
    }

}
